home *** CD-ROM | disk | FTP | other *** search
/ Executor 2.0 / executorv2.0.iso / mac / demoware / Asymptote 1.1 Demo / Scripts / Demos / 3) Graphics / demo3
Encoding:
Text File  |  1994-11-01  |  6.2 KB  |  393 lines  |  [TEXT/DWat]

  1. % Demo some of the various 
  2. % graphics features of Asymptote
  3.  
  4. npts 0        % To clear out the labels
  5. graphunits inches
  6. graphframe 0.5 8 1.25 10
  7. scale 2
  8. drawtitle Asymptote Graphics in Color
  9. scale 1
  10.  
  11. graphframe 0.5 8 1 9
  12. graphpane_setup 3 3 0.25 0.5
  13. graphlimits 0 11 0 11
  14.  
  15. % Point symbols
  16. graphpane 1 3
  17. fullscreen yes
  18. drawframe inside outside noticks nolabels nolabels nolabels nolabels
  19. drawtitle POINT SYMBOLS
  20. npts 10
  21. xrange 1 10
  22. rpn <y 1 >y
  23. rpn <x 10 * open + >p
  24. rpn <y 1 + >y
  25. plotpoints
  26. rpn <x 10 * cross + >p
  27. rpn <y 1 + >y
  28. pencolor blue
  29. plotpoints
  30. rpn <x 10 * star + >p
  31. rpn <y 1 + >y
  32. pencolor red
  33. plotpoints
  34. rpn <x 10 * filled + >p
  35. rpn <y 1 + >y
  36. pencolor green
  37. plotpoints
  38. rpn <x 10 * open + chs >p
  39. rpn <y 1 + >y
  40. penpattern gray
  41. pensize 1
  42. pencolor magenta
  43. plotpoints
  44. rpn <x 10 * cross + chs >p
  45. rpn <y 1 + >y
  46. pencolor blue
  47. penpattern black
  48. pensize 0.5
  49. plotpoints
  50. rpn <x 10 * star + chs >p
  51. rpn <y 1 + >y
  52. pensize 0.25
  53. pencolor yellow
  54. plotpoints
  55. fillpattern none
  56. pencolor green
  57. plotpoints
  58. rpn <x 10 * filled + chs >p
  59. rpn <y 1 + >y
  60. fillpattern gray
  61. pensize 0.5
  62. plotpoints
  63. fillpattern none
  64. pencolor red
  65. plotpoints
  66.  
  67. pensize 0.25
  68. penpattern black
  69. fillpattern black
  70. pencolor black
  71.  
  72. % Error bars
  73. graphpane 1 2
  74. showgraph
  75. drawframe inside outside noticks nolabels nolabels nolabels nolabels
  76. drawtitle ERROR BARS && LIMITS
  77. xrange 1 10
  78. rpn ran 1 + 4 * 2 + >y
  79. rpn ran 2 + 1.5 / ran 0 < -1 * dup 0 = + * >e
  80. ploterrors left
  81. rpn ran 2 + 1.5 / ran 0 < -1 * dup 0 = + * >e
  82. ploterrors right
  83. rpn ran 2 + 1.5 / ran 0 < -1 * dup 0 = + * >e
  84. ploterrors top
  85. rpn ran 2 + 1.5 / ran 0 < -1 * dup 0 = + * >e
  86. ploterrors bottom
  87. pointsymbol 4 filled
  88. pointsize 4
  89. pencolor red
  90. plotpoints
  91.  
  92. % Set up to errors with no cross bars or arrows, just lines
  93. pencolor blue
  94. scale 0
  95. rpn ran 1 + 4 * 2 + >y
  96. rpn ran 2 + 1.5 / ran 0 < -1 * dup 0 = + * >e
  97. ploterrors left
  98. rpn ran 2 + 1.5 / ran 0 < -1 * dup 0 = + * >e
  99. ploterrors right
  100. rpn ran 2 + 1.5 / ran 0 < -1 * dup 0 = + * >e
  101. ploterrors top
  102. rpn ran 2 + 1.5 / ran 0 < -1 * dup 0 = + * >e
  103. ploterrors bottom
  104. pointsymbol 4 filled
  105. pointsize 4
  106. pencolor red
  107. scale 1
  108. plotpoints
  109.  
  110. pencolor black
  111. showgraph
  112.  
  113. % Pen dashes & patterns
  114. graphpane 1 1
  115. showgraph
  116. drawtitle PEN DASHES && PATTERNS
  117. drawframe inside outside noticks nolabels nolabels nolabels nolabels
  118. moveto 1 1
  119. pensize 1
  120. penpattern black
  121. pendash long short
  122. pencolor y 10 * 0 100 y 10 * -
  123. drawto 10 y
  124.  
  125. moveto 1 y 1 +
  126. pensize 1
  127. penpattern gray
  128. pendash long short short short
  129. pencolor y 10 * 0 100 y 10 * -
  130. drawto 10 y
  131.  
  132. moveto 1 y 1 +
  133. pensize 0.25
  134. penpattern black
  135. pendash dot
  136. pencolor y 10 * 0 100 y 10 * -
  137. drawto 10 y
  138.  
  139. moveto 1 y 1 +
  140. pensize 1
  141. penpattern lightgray
  142. pendash long short long short
  143. pencolor y 10 * 0 100 y 10 * -
  144. drawto 10 y
  145.  
  146. moveto 1 y 1 +
  147. pensize 1
  148. penpattern black
  149. pendash dot dot long dot dot dot
  150. pencolor y 10 * 0 100 y 10 * -
  151. drawto 10 y
  152.  
  153. moveto 1 y 1 +
  154. pensize 1
  155. penpattern darkgray
  156. pendash short dot dot dot
  157. pencolor y 10 * 0 100 y 10 * -
  158. drawto 10 y
  159.  
  160. moveto 1 y 1 +
  161. pensize 0.5
  162. penpattern black
  163. pendash long dot dot dot dot dot
  164. pencolor y 10 * 0 100 y 10 * -
  165. drawto 10 y
  166.  
  167. moveto 1 y 1 +
  168. pensize 1
  169. penpattern black
  170. pendash dot dot dot short short short
  171. pencolor y 10 * 0 100 y 10 * -
  172. drawto 10 y
  173.  
  174. moveto 1 y 1 +
  175. pensize 3
  176. penpattern black
  177. pendash long short
  178. pencolor y 10 * 0 100 y 10 * -
  179. drawto 10 y
  180.  
  181. moveto 1 y 1 +
  182. pensize 4
  183. penpattern diagonal
  184. pendash solid
  185. pencolor y 10 * 0 100 y 10 * -
  186. drawto 10 y
  187.  
  188. pensize 0.25
  189. pendash solid
  190. penpattern black
  191. pencolor black
  192.  
  193. % Fonts rotated text
  194. graphpane 2 3
  195. showgraph
  196. drawtitle LABELS && TEXT
  197. drawframe inside outside noticks nolabels nolabels nolabels nolabels
  198.  
  199. moveto 2 2
  200. fontname times
  201. fontsize 24
  202. drawlabel center Label
  203.  
  204. moveto 5 5
  205. fontname Times
  206. fontsize 12
  207. rotation 45
  208. pencolor 90 78 34
  209. drawlabel center y = 34 x\\u2 + 45.93
  210.  
  211. moveto 7 2
  212. fontname Helvetica
  213. fontsize 24
  214. rotation 90
  215. pencolor red
  216. drawlabel center \st\\dH\d2O 
  217.  
  218. moveto 8 8
  219. fontname Palatino
  220. fontsize 24
  221. rotation 0
  222. pencolor blue
  223. drawlabel center y = e\\u-\ii\spx\sn
  224.  
  225. moveto 1 10
  226. fontname Courier
  227. fontsize 8
  228. rotation 0
  229. pencolor 50 50 50
  230. drawlabel centerright Date:\# Time:\@
  231.  
  232. moveto 1 5
  233. fontname Times
  234. fontsize 12
  235. rotation -45
  236. pencolor black
  237. drawlabel center \\iitalic
  238.  
  239. moveto 10 3
  240. fontname Times
  241. fontsize 12
  242. rotation -45
  243. drawlabel centerleft \\sT/E - n/i
  244.  
  245. moveto 3 7
  246. fontname Helvetica
  247. fontsize 12
  248. rotation 270
  249. drawlabel center TESTING
  250.  
  251. rotation 0
  252. fontname Helvetica
  253. fontsize
  254.  
  255.  
  256. % Plot histogram
  257. graphpane 2 2
  258. showgraph
  259. drawtitle PLOT HISTOGRAMS
  260. drawframe inside outside noticks nolabels nolabels nolabels nolabels
  261.  
  262. npts 36
  263. xrange -10 10
  264. rpn deg <x dup * -3 / e^x >y
  265. graphlimits
  266. fillpattern diagonal
  267. plothistogram 0
  268.  
  269. % Plot polygon
  270. graphpane 2 1
  271. showgraph
  272. drawtitle PLOT POLYGONS
  273. drawframe inside outside noticks nolabels nolabels nolabels nolabels
  274. npts 7
  275.  
  276. rpn ran >x ran >y
  277. sort
  278. graphlimits
  279. fillpattern darkgray
  280. penpattern gray
  281. pendash long
  282. pencolor blue
  283. plotpolygon closed
  284.  
  285. pencolor black
  286. penpattern black
  287. fillpattern black
  288. pendash solid
  289.  
  290. % Plot points & line
  291. graphpane 3 3
  292. showgraph
  293. drawtitle PLOT LINES && POINTS
  294. drawframe inside outside noticks nolabels nolabels nolabels nolabels
  295. pointsize 4
  296.  
  297. npts 5
  298. rpn ran >x ran >y
  299. sort
  300. spline
  301. graphlimits
  302. pendash solid
  303. pensize 0.5
  304. pencolor 50 100 50
  305. plotline
  306. pensize 0.25
  307. pointsymbol 4 filled
  308. pencolor red
  309. plotpoints
  310.  
  311. npts 5
  312. rpn ran >x ran >y
  313. sort
  314. spline 
  315. graphlimits
  316. pendash short dot dot dot
  317. pensize 0.5
  318. pencolor 100 50 50
  319. plotline
  320. pensize 0.25
  321. pencolor cyan
  322. plotpoints
  323.  
  324. npts 5
  325. rpn ran >x ran >y
  326. sort
  327. spline
  328. graphlimits
  329. pendash dot
  330. pensize 0.5
  331. pencolor 50 50 100
  332. plotline
  333. pensize 0.25
  334. pencolor magenta
  335. plotpoints
  336.  
  337. pensize 0.15
  338. pendash solid
  339. pencolor black
  340.  
  341. % Plot arrows
  342. graphpane 3 2
  343. showgraph
  344. drawtitle PLOT ARROWS
  345. drawframe inside outside noticks nolabels nolabels nolabels nolabels
  346. npts 30
  347.  
  348. xrange 0 360
  349. rpn deg <x dup sin 2 * >x drop cos 2 * >y
  350.  
  351. graphlimits -5 5 -5 5
  352. rpn <y 2 * <x 2 * <y <x roll+2
  353. pencolor blue
  354. plotarrows
  355. pointsymbol 20 filled
  356. pencolor 10 90 10
  357. plotpoints
  358.  
  359. pencolor black
  360.  
  361. % Plot labels
  362. graphpane 3 1
  363. showgraph
  364. drawtitle PLOT LABELS
  365. drawframe inside outside noticks nolabels nolabels nolabels nolabels
  366.  
  367. npts 7
  368. rpn ran >x ran >y
  369. datafile Test Data
  370. datalines 2
  371. readcolumn l 1
  372. closewindow \f
  373. graphlimits -1.5 1.5 -1.5 1.5
  374. pointsymbol 4 filled
  375. pencolor 80 40 80
  376. plotpoints
  377. rpn <x 0.1 + >x
  378. pencolor red
  379. plotlabels centerright
  380. npts 0        % To clear out the labels
  381.  
  382.  
  383. closewindow xrange
  384. closewindow graphpane_setup
  385. closewindow graphpane
  386.  
  387. showpage
  388.  
  389.  
  390.  
  391.  
  392.  
  393.